#include <iostream>
using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

int n,m;
LL qh[N];

int main(){
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        LL x;
        cin >> x;
        qh[i] = x + qh[i - 1];
    }
    while(m--){
        int le,ri;
        cin >> le >> ri;
        cout << qh[ri] - qh[le - 1] << endl;
    }
    return 0;
}
